<template>
  <div class="component-groupProd">
    <el-dialog
      v-model="visible"
      :title="$t('groups.commSpenMan')"
      :modal="true"
      width="50%"
      append-to-body
    >
      <!-- 填写多个商品规格设置 -->
      <div v-if="true">
        <el-table
          :data="dataForm.skuDtoList"
          header-cell-class-name="table-header"
          row-class-name="table-row-low"
          style="width: 100%"
        >
          <el-table-column
            prop="skuName"
            :label="$t('groups.skuName')"
            width="180"
          >
            <template #default="scope">
              {{ scope.row.skuName ==="" || scope.row.skuName?dataForm.prodName:scope.row.skuName }}
            </template>
          </el-table-column>
          <!-- 销售价(元) -->
          <el-table-column
            prop="price"
            :label="$t('prodList.salesPrice')"
            width="180"
          />
          <!-- 拼团价(元) -->
          <el-table-column
            prop="actPrice"
            :label="$t('groups.groupPriceYuan')"
          >
            <template #default="scope">
              <el-input
                v-model="scope.row.actPrice"

                :disabled="true"
              />
            </template>
          </el-table-column>
          <!-- 团长价(元) -->
          <el-table-column
            v-if="dataForm.hasLeaderPrice === 1"
            prop="leaderPrice"
            :label="$t('groups.headPriceYuan')"
          >
            <template #default="scope">
              <el-input
                v-model="scope.row.leaderPrice"

                :disabled="true"
              />
            </template>
          </el-table-column>
          <el-table-column
            prop="stocks"
            :label="$t('groups.stock')"
            align="center"
          />
        </el-table>
      </div>

      <template #footer>
        <div class="dialog-footer">
          <div
            class="default-btn primary-btn"
            @click="visible = false"
          >
            {{ $t('groups.determine') }}
          </div>
        </div>
      </template>
    </el-dialog>
  </div>
</template>
<script setup>
const visible = ref(false)
const dataForm = ref({})
const init = (groupProdId) => {
  visible.value = true
  nextTick(() => {
    if (groupProdId) {
      http({
        url: http.adornUrl('/platform/group/prod/getGroupProdAndSkuList/' + groupProdId),
        method: 'get',
        params: http.adornParams()
      })
        .then(({ data }) => {
          dataForm.value = data
        })
    }
  })
}
defineExpose({ init })
</script>
